require(['jquery', 'cookie', 'app', "lay"], function ($) {
    require(['vue'], function (Vue) {
        var dic = new Vue({
            el: ".vue-box"
            , data: {
                where: "",
                that: {
                    name: "",
                    series: "",
                    parentId: "",
                    status: false,
                    id:""
                }
            }
            , created: function () {
                this.loadPage();
            }
            , methods: {
                loadPage: function () {
                    load();
                    var toolbar = [];
                    toolbar.push({
                        "clas": "layui-icon layui-icon-add-1",
                        "eve": "ADD",
                        "tit": "新增",
                        "fnc": function (data) {
                            dic.openAdd();
                        }
                    });
                    var tool = [];
                    tool.push({
                        "clas": "layui-btn-danger",
                        "eve": "UPDATE",
                        "tit": "修改",
                        "fnc": function (data) {
                            dic.that = data.data;
                            dic.that['status'] = false;
                            dic.that['password']="";
                            dic.that['frmRoles']="";
                            dic.openAdd();
                        }
                    });
                    treeTab($("#authoritiesTable"), "/service-shop/ClassifyController/getClassify", [
                        {type: 'checkbox'},
                        {type: 'numbers'},
                        {field: 'id', title: 'id', minWidth: 120},
                        {field: 'name', title: '分类名称', minWidth: 120},
                        {field: 'series', title: '分类级数', minWidth: 120},
                        {field: 'parentId', title: '父分类ID', minWidth: 120},
                        {
                            templet: '<p>{{# if(d.status==false){ }} 禁用 {{# } }}{{# if(d.status==true){ }} 启用 {{# } }}</p>',
                            align: 'center',
                            width: 100,
                            title: '状态'
                            , minWidth: 120
                        },
                        {title: '操作', toolbar: '#authoritiesTbBar', align: 'center', width: 120}
                    ],function (data) {

                    },this.where, toolbar, tool);
                },
                seachs: function () {
                    this.where = fromName($(".el-form"));
                    this.loadPage();
                },
                refer: function () {

                },
                openAdd: function () {
                    alrYN($("#admins"), function () {
                        var jon = dic.that;
                        jon['status'] = $('input[name="status"]').next().find("em").text();
                        var ret = playPost("service-shop/ClassifyController/classify", "", JSON.stringify(jon));
                        alr(ret.msg);
                    }, function () {

                    }, function () {

                    }, "新增分类", 1, ["600px", "350px"]);
                }
            }
        });
    })
});